package per.lee.spingboothelper.db.config;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 优化，根据表达式规则生成值
 * @author lxy
 *
 */
public class ColumnValueConfig {
	
	public static final List<String> TABLE_LIST = Arrays.asList("ads_nuc_rpt_backfatdist_month");

	public static final Map<String, List<String>> FIELD_VALUE = new HashMap<String, List<String>>();

	//枚举值
	public static final Map<String, String> FIELD_RULE = new HashMap<String, String>();

	public static final Map<String, List<String>> LSAT_RULE = new HashMap<String, List<String>>();

	static {
		List<String> dayList = new ArrayList<String>();
		List<String> monthList = new ArrayList<String>();
		for (int i = 1; i < 30; i++) {
			if(i<10) {
				dayList.add("0" + i);
			}else {
				dayList.add("" + i);
			}

			if (i < 13) {
				if(i<10) {
					monthList.add("0"+i );
				}else {
					monthList.add(""+i );
				}
			}
		}
		FIELD_VALUE.put("dt_year", Arrays.asList("2015", "2016", "2017", "2018", "2019"));
		FIELD_VALUE.put("dt_month", monthList);
		FIELD_VALUE.put("dt_day", dayList);
		FIELD_VALUE.put("tenant_id", Arrays.asList("161276570647068674"));
		FIELD_VALUE.put("farm_id", Arrays.asList("162391213712998400", "162672088468029440", "162689143246290944"));
		FIELD_VALUE.put("category_type", Arrays.asList("00", "01"));
		
		
//		scale_code	varchar(20)	评定结果代码(00-适中，01-轻微偏瘦，02-轻微偏肥，03-严重偏瘦，04-严重偏肥)
		FIELD_VALUE.put("scale_code", Arrays.asList("00", "01", "02","03","04"));
		FIELD_VALUE.put("parity", Arrays.asList("0","1", "2", "3","4","5"));
		FIELD_VALUE.put("strain_code", Arrays.asList("USAS","DENS"));
		FIELD_VALUE.put("stage_code", Arrays.asList("weaningToMating","entryToMating","farrowToDelivery"));
		
		List<String> scaleList = new ArrayList<String>();
		for (int i = 80; i < 300; i+=5) {
			scaleList.add(i+"");
		}
		FIELD_VALUE.put("scale_lower", scaleList);
		FIELD_VALUE.put("scale_upper", scaleList);
		
		
		List<String> dtList = new ArrayList<String>();
		FIELD_VALUE.get("dt_year").forEach(y->{
			FIELD_VALUE.get("dt_month").forEach(m->{
				FIELD_VALUE.get("dt_day").forEach(d->{
					dtList.add(y+m+d);
				});
			});
		});
		dtList.clear();
		//只有年的情况
		FIELD_VALUE.get("dt_year").forEach(y->{
			dtList.add(y);
		});
		LSAT_RULE.put("dt",dtList);
	
		FIELD_RULE.put("dt", "<<dt_year>>");
//		FIELD_RULE.put("dt", "<<dt_year>><<dt_month>><<dt_day>>");
	}


}
